<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文章列表</title> 
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="/public/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/public/admin/css/animate.css" rel="stylesheet">
    <link href="/public/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <link href="/public/admin/js/plugins/layer/skin/layer.css" rel="stylesheet">
    <base target="_blank">
    <!-- 全局js -->
    <script src="/public/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/admin/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="/public/admin/js/plugins/layer/layer.min.js"></script> 
    <!-- 自定义js -->
    <script src="/public/admin/js/content.js?v=1.0.0"></script>
    <script src="/public/admin/js/contabs.js"></script>
    <script src="/public/admin/js/common.js"></script>
    <script src="/public/admin/js/article.js"></script> 

    <!-- Bootstrap table -->
    <script src="/public/admin/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/public/admin/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="/public/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>    
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>文章列表</h5> 
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                                <div class="box-header">
                                    <div class="panel-body">
                                            <div>
                                        <form id="formSearch" class="form-horizontal form-inline" style="display:none;">
                                                <label class="control-label">文章栏目：</label>
                                                <select class="form-control" name="kind_id">
                                                    <option value="">所有栏目</option>
                                                    {$cat_select}
                                                </select>
                                                <!-- <label class="control-label">关键字：</label>
                                                <input type="text" placeholder="标题关键字" name="keyword" id="keyword" class="form-control"> -->
                                                <button type="button" style="margin-left:30px" onclick="getAjaxList('ajaxList',1,'/index.php/Admin/Article/GetArticleList')" id="btn_query" class="btn btn-primary">查询</button>
                                                <a onclick="openYemian('/index.php/Admin/Article/article','添加文章')" href="javascript:;" class="btn btn-primary pull-right"><i class="fa fa-plus"></i>添加</a>
                                                <a onclick="javascript:window.location.href=location.href;" href="javascript:;" class="btn btn-primary pull-right" style="margin-right:10px;"><i class="glyphicon glyphicon-refresh"></i>刷新</a>
                                        </form>
                                            </div>
                                    </div>                  
                                </div><!-- /.box-header -->
                                <div class="box-body">
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div id="ajaxList">
                                                <form method="post" enctype="multipart/form-data" id="form-order">
                                                <table class="table table-bordered">
                                                    <thead>
                                                        <tr>
                                                            <th style="width: 1px;"><input type="checkbox" onclick="$('input[name*=\'ids\']').prop('checked', this.checked);"></th>
                                                            <th>文章ID</th>
                                                            <th>文章标题</th>
                                                            <th>所属类别</th>
                                                            <th>文章序号</th> 
                                                            <th>添加时间</th>
                                                            <th>操作</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody id="ajaxList"> 
                                                        {foreach name="list" item="vo" key="k" }
                                                          <tr role="row">
                                                            <td><input type="checkbox" name="ids[]" value="{$vo.article_id}"></td>
                                                            <td>{$vo.article_id}</td>
                                                            <td>{$vo.title|getSubstr=0,33}</td>
                                                            <td>{$vo.category}</td>
                                                            <td>{$vo.sort_order}</td> 
                                                            <td>{$vo.add_time}</td>
                                                            <td>
                                                              <a class="btn btn-primary" href="javascript:;" title="还原" onclick="delarticle(this,'确定还原该文章吗？',{$vo.article_id},'/index.php/Admin/Article/articleEndReback')" target="_self"><i class="fa fa-edit"></i></a>
                                                              <a class="btn btn-danger" href="javascript:void(0)" title="删除" data-url="{:url('Article/aticleHandle')}" data-id="{$vo.article_id}" onclick="delarticle(this,'确定删除该文章吗？此操作不可恢复！',{$vo.article_id},'/index.php/Admin/Article/articleEnddel')" target="_self"><i class="fa fa-trash-o"></i></a>
                                                            </td>
                                                          </tr>
                                                        {/foreach}
                                                    </tbody>
                                                </table>
                                                </form>   
                                                <div>
                                                    <div style="float:left;"><a href="javascript:void(0);" onclick="delselect()" id="button-delete6" data-toggle="tooltip" title="删除" class="btn btn-danger" data-original-title="删除">删除选中</a></div>
                                                </div>                                             
                                            </div>
                                        </div>
                                    </div>
                                </div> <!-- /.box-body -->
                           </div><!-- /.box -->
                        </div>
                   </div>
                </div>
            </div>
        </div>
    </div> 
</div> 

<input id="handle_status" value="" hidden="hidden">
 
<script>
function delarticle(obj,name,id,url) {
    top.layer.confirm(name,{
        icon : 3,
        btn:['确定','取消'],
    } , function(){
        $.ajax({
            url : url,
            type : "post",
            data : {article_id:id,act:'del'},
            dataType : "json",
            success:function(data){
                if (data.status == 0) { 
                    top.layer.msg(data.message);
                } else {
                    top.layer.msg(data.message);
                    $(obj).parent().parent().remove();
                }
            }
        });
    } , function(){
        layer.close(); //再执行关闭 
    })
}

    // getAjaxList('ajaxList',1,'/index.php/Admin/Article/GetArticleList');
// 删除选中
    function delselect(){
        parent.layer.confirm('确定要删除选中吗？此操作不可恢复', function(){
            url = window.location.href;
            $.ajax({
                url:"/index.php/Admin/article/delselect",
                data : $('#form-order').serialize(),
                success: function(v){
                    var v =  eval('('+v+')');
                    parent.layer.msg(v.message, {icon: v.icon,time: 1000});
                    window.location = window.location;
                    // if(v.hasOwnProperty('status') && (v.status == 1))
                        // getAjaxList('ajaxList',1,"/index.php/Admin/Article/ajaxArticleList");
                }
            });
        });
    }
</script>

</body>

</html>